package com.project.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.MainPostBean;
import com.project.mapper.IMainPostMapper;
import com.project.service.IMainPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;

@Service("MainPostServiceImpl")
@Transactional
public class MainPostServiceImpl implements IMainPostService {
    @Autowired
    private IMainPostMapper mapper;

    @Override
    public IPage<MainPostBean> cutByItem(Integer id, Integer pageNo, String title, String author, LocalDate startDate, LocalDate endDate) {

        return mapper.cutByItem(id, new Page(pageNo, 3), title, author, startDate, endDate);
    }

    @Override
    public void add(MainPostBean postBean) {
        mapper.insert(postBean);
    }

    @Override
    public MainPostBean findById(Integer postId) {
        return mapper.findById(postId);
    }
}
